This is a draft of a tech note about setting the FLUSH equal to zero to speed up the importation of data. Setting the FLUSH to zero is a way of overriding 4D's conservative approach to saving to disk all the time and letting the Macintosh decided when the buffer is full.
There is a system variable called FLUSH that can be used to speed up several
operations in 4th Dimension. FLUSH is a potentially dangerous variable, that
must be used only if it is absolutely neccessary. All operations that save
data (ADD RECORD, APPLY TO SELECTION, DELETE DOCUMENT, DELETE RECORD, DELETE SELECTION, IMPORT DIF, IMPORT SYLK, IMPORT TEXT, MODIFY RECORD, MODIFY SELECTION, SAVE LINKED RECORD, SAVE OLD LINKED RECORD, SAVE RECORD, SAVE SET, SAVE VARIABLE) use this variable.
The default setting of FLUSH is 1. With this setting, when a save is performed, the descriptive information about the volume, the contents of the volume buffer and all associated access path buffers are written out.
You can set FLUSH to zero before doing a series of saves. By doing this, every time a save is performed, all the information is NOT written to the volume. This speeds up each save considerably.
IT IS EXTREMELY IMPORTANT THAT YOU RESET FLUSH TO 1 AFTER YOU ARE DONE. This will update all the information on the volume.
Typically, when you are in importing records:
DEFAULT FILE([Employees])
SET CHANNEL(13;"")
IF (OK=1)
fldDelimit:=206
' system variable for field delimiter
rcdDelimit:=207
' system variable for record delimiter
INPUT LAYOUT("emp.import")
flush:=O
' This will stop flushing for every record that is received.
Set FLUSH to O before starting the While loop for receiving records. This will
speed up the SAVE RECORD command. When all the records are received, set FLUSHback to 1. This will update all the information of the saved records.
IMPORTANT: If there is an interruption, such as a power failure, while FLUSH is O, then all data entered since FLUSH was set to O will be lost. This can also damage the database and you will have to run 4th Dimension Utilities to repair it.
THE DECISION TO USE FLUSH SHOULD ENTIRELY BE BASED ON HOW FREQUENTLY YOU NEED TO UPDATE THE VOLUME WHEN SAVING RECORDS. REMEMBER, USE FLUSH WITH CARE. IT IS BETTER TO BE SLOWER THEN TO LOSE DATA.